<template>
    <div class="app-container">
        <div v-if="opt != 'add'">
            <el-descriptions title="">
                <el-descriptions-item label="序号">
                    <el-tag size="medium">{{ obj != null ? obj.index : index }}</el-tag>
                </el-descriptions-item>
            </el-descriptions>
        </div>
        <el-tabs v-model="activeName" @tab-click="handleClick" style="margin:0px 6px 0px 8px;">
            <el-tab-pane label="商机信息" name="first">
                <!-- 添加或修改【请填写功能名称】对话框 -->
                <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="商机名称" prop="businessName" label-width="110px">
                                <el-input v-model="form.businessName" placeholder="请输入商机名称" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="创建时间" prop="creationTime" label-width="110px">
                                <el-input v-model="form.creationTime" disabled="disabled" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="客户名称" prop="enterpriseName" label-width="110px">
                                <el-input v-model="form.enterpriseName" disabled="disabled" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="商机类型" prop="businessType" label-width="110px">
                                <el-select v-model="form.businessType" placeholder="请选择商机类型" style="width: 294px;">
                                    <el-option v-for="dict in dict.type.business_classify" :key="dict.value"
                                        :label="dict.label" :value="dict.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="商机来源" prop="businessSource" label-width="110px">
                                <el-select v-model="form.businessSource" placeholder="请选择跟单阶段" style="width: 294px;">
                                    <el-option v-for="dict in dict.type.business_source" :key="dict.value"
                                        :label="dict.label" :value="dict.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="商机状态" prop="businessState" label-width="110px">
                                <el-select v-model="form.businessState" placeholder="请选择商机状态" style="width: 294px;">
                                    <el-option v-for="dict in dict.type.business_state" :key="dict.value"
                                        :label="dict.label" :value="dict.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="联系人姓名" prop="contacts" label-width="110px">
                                <el-input v-model="form.contacts" placeholder="请输入联系人姓名" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="联系人电话" prop="telephone" label-width="110px">
                                <el-input v-model="form.telephone" placeholder="请输入联系人电话" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="联系人职位" prop="position" label-width="110px">
                                <el-input v-model="form.position" placeholder="请输入联系人职位" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="商机提供人" prop="businessProvider" label-width="110px">
                                <el-input v-model="form.businessProvider" placeholder="请输入商机提供人" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="预计成交时间" prop="expectedDate" label-width="110px">
                                <el-date-picker clearable v-model="form.expectedDate" type="date"
                                    value-format="yyyy-MM-dd" :picker-options="{ disabledDate: dateOptions }"
                                    placeholder="请选择预计成交日期" :editable="false" style="width: 294px;">
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="创建人" prop="creationName" label-width="110px">
                                <el-input v-model="form.creationName" placeholder="请输入创建人" disabled="disabled" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="跟单阶段" prop="trackingStage" label-width="110px">
                                <el-select v-model="form.trackingStage" placeholder="请选择跟单阶段" style="width: 294px;">
                                    <el-option v-for="dict in dict.type.tracking_stage" :key="dict.value"
                                        :label="dict.label" :value="dict.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="协作人" prop="collaboratorName" label-width="110px">
                                <el-input v-model="form.collaboratorName" placeholder="请选择协作人" @focus="userShow(4)"
                                    :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="开发经理" prop="developmentManager" label-width="110px">
                                <el-input v-model="form.developmentManager" placeholder="请选择开发经理" @focus="userShow(2)"
                                    :readonly="readonly" :disabled="isOpt" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="业务经理" prop="businessManager" label-width="110px">
                                <el-input v-model="form.businessManager" placeholder="请选择业务经理" @focus="userShow(3)"
                                    :readonly="readonly" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" style="height: 55px;">
                            <el-form-item label="附件" label-width="110px">
                                <file-view :type="fileType" :businessId="businessId" :businessCode="businessCode"
                                    @change="getFile"></file-view>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <div style="text-align: center;margin-top: 50px;">
                    <!-- <el-button type="primary" @click="submitFormOnce" v-if="isTwoSave">连续新增</el-button> -->
                    <el-button type="primary" @click="submitForm">保 存</el-button>
                    <el-button @click="cancel">关 闭</el-button>
                </div>
            </el-tab-pane>
            <el-tab-pane label="跟进记录" name="second" :disabled="isSwitch">
                <div style="text-align: center;">
                    <BusinessRecords :key="new Date().getTime()" :bId="bId"></BusinessRecords>
                </div>
                <div style="text-align: center;margin-top: 50px;">
                    <el-button @click="cancel">关 闭</el-button>
                </div>
            </el-tab-pane>
        </el-tabs>
        <select-user ref="select" :type="userType" :sign="sign" @ok="selectUser"></select-user>
        <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
            <el-tabs v-model="activeNewName" @tab-click="handleNewClick" type="card">
                <el-tab-pane label="客户" name="one">
                    <el-row>
                        <el-col :span="5">
                            <MainType :typeCode="0" @getNode="getNodeEnterprise" :isTree="isTree"></MainType>
                        </el-col>
                        <el-col :span="19">
                            <el-form :model="queryEnterpriseParams" ref="queryFormEnterprise" size="small"
                                :inline="true" v-show="showSearch" label-width="100px">
                                <el-form-item label="企业名称" prop="enterpriseName">
                                    <el-input v-model="queryEnterpriseParams.enterpriseName" placeholder="请输入企业名称"
                                        clearable @keyup.enter.native="handleQueryEnterprise" />
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" icon="el-icon-search" size="mini"
                                        @click="handleQueryEnterprise">搜索</el-button>
                                    <el-button icon="el-icon-refresh" size="mini"
                                        @click="resetQueryEnterprise">重置</el-button>
                                    <el-button type="primary" size="mini" @click="saveSelectEnterprise">确定</el-button>
                                </el-form-item>
                            </el-form>
                            <el-table ref="tableEnterprise" v-loading="loading" style="width: 100%"
                                @selection-change="handleSelectionChangeEnterprise" :data="infoList">
                                <el-table-column type="selection" width="45" align="center" />
                                <el-table-column label="企业名称" align="center" prop="enterpriseName" />
                                <el-table-column label="联系人" align="center" prop="contacts" />
                                <el-table-column label="联系电话" align="center" prop="telephone"
                                    show-overflow-tooltip="true" />
                            </el-table>
                            <pagination v-show="total1 > 0" :total="total1" :page.sync="queryEnterpriseParams.pageNum"
                                :limit.sync="queryEnterpriseParams.pageSize" @pagination="getEnterpriseList" />
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="公海" name="two">
                    <el-row>
                        <el-col :span="5">
                            <MainType :typeCode="seasTypeCode" @getNode="getNodeSeas" :isTree="isTree"></MainType>
                        </el-col>
                        <el-col :span="19" :xs="24">
                            <el-form :model="querySeasParams" ref="queryFormSeas" size="small" :inline="true"
                                v-show="showSearch" label-width="100px">
                                <el-form-item label="企业名称" prop="enterpriseName">
                                    <el-input v-model="querySeasParams.enterpriseName" placeholder="请输入企业名称" clearable
                                        @keyup.enter.native="handleQuerySeas" />
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" icon="el-icon-search" size="mini"
                                        @click="handleQuerySeas">搜索</el-button>
                                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuerySeas">重置</el-button>
                                    <el-button type="primary" size="mini" @click="saveSelectSeas">确定</el-button>
                                </el-form-item>
                            </el-form>

                            <el-table ref="tableSeas" v-loading="loading" :data="seasList"
                                @selection-change="handleSelectionChangeSeas">
                                <el-table-column type="selection" width="45" align="center" />
                                <el-table-column label="企业名称" align="center" prop="enterpriseName" />
                                <el-table-column label="联系人" align="center" prop="contacts" />
                                <el-table-column label="联系电话" align="center" prop="telephone" />
                            </el-table>
                            <pagination v-show="total2 > 0" :total="total2" :page.sync="querySeasParams.pageNum"
                                :limit.sync="querySeasParams.pageSize" @pagination="getSeasList" />
                        </el-col>
                    </el-row>
                </el-tab-pane>
            </el-tabs></el-dialog>
    </div>
</template>

<script>
import { listInformation, getInformation, delInformation, addInformation, updateInformation } from "@/api/enterprise/information";
import { getSupplierInfo } from "@/api/supplier/supplier";
import { listSeas, getSeas } from "@/api/highSeas/seas";
import { listInfo, getInfo } from "@/api/enterprise/info";
import FileView from "@/components/FileView/index"
import SelectUser from "../system/role/selectUser.vue";
import { listType } from "@/api/maintype/type";
import Treeselect from "@riophae/vue-treeselect";
import Seas from '../enterprise/seas/index.vue';
import MainType from "@/components/MainType/index"
import BusinessRecords from '../records/records.vue'
import EnterpriseInfo from "../enterprise/info/index.vue";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
    name: "BusinessManager",
    dicts: ['business_classify', 'customer_industry', 'business_state', 'tracking_stage', 'enterprise_records', 'business_source'],
    components: { Treeselect, SelectUser, FileView, EnterpriseInfo, BusinessRecords, Seas, MainType },
    props: {
        opt: {
            type: String,
            default: ""
        },
        seas: {
            type: String,
            default: "0"
        },
        id: {
            type: String,
            default: ""
        },
        obj: {
            type: Object,
            default: null
        },
        //序号
        index: {
            type: Number,
            default: 0
        },
        uuid: {
            type: String,
            default: ""
        },
        isClick: {
            type: Boolean,
            default: ""
        },
        classId: {
            type: String,
            default: ""
        },
        enterpriseId: {
            type: String,
            default: ""
        },
        enterpriseName: {
            type: String,
            default: ""
        },
        business: {
            type: Object,
            default: null
        }
    },
    data() {
        var developmentManager = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('开发经理不能为空'));
            }
            return callback()
        };
        var businessManager = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('业务经理不能为空'));
            }
            return callback()
        };
        var collaboratorName = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('协作人不能为空'));
            }
            return callback()
        };
        var enterpriseName = (rule, value, callback) => {
            value = this.form.enterpriseName
            if (!value) {
                return callback(new Error('客户名称不能为空'));
            }
            return callback()
        };
        var contacts = (rule, value, callback) => {
            value = this.form.contacts
            if (!value) {
                return callback(new Error('联系人不能为空'));
            }
            return callback()
        };
        var telephone = (rule, value, callback) => {
            value = this.form.telephone
            if (!value) {
                return callback(new Error('联系人电话不能为空'));
            }
            return callback()
        };
        var classificationId = (rule, value, callback) => {
            if (!value) {
                return callback(new Error('主分类不能为空'));
            }
            return callback()
        };
        return {
            routerType: null,
            isOpt: false,
            isTwoSave: false,
            isTree: false,
            seasTypeCode: 'seas',
            readonly: true,
            isSwitch: true,
            bId: "",
            refreshKey: 0,
            //选显卡默认选中
            activeName: 'first',
            activeNewName: 'one',
            userType: "1",
            sign: '1',
            // 遮罩层
            loading: true,
            // 选中数组
            eIds: [],
            sIds: [],
            sContacts: [],
            eContacts: [],
            sTeles: [],
            eTeles: [],
            eName: [],
            sName: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            total1: 0,
            total2: 0,
            // 【请填写功能名称】表格数据
            informationList: [],
            infoList: [],
            seasList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            fileType: 0,
            businessCode: 'businessinfo',
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 15,
                businessName: null,
                classificationId: null,
                enterpriseId: null,
                enterpriseName: null,
                businessState: null,
                businessType: null,
                businessSource: null,
                contacts: null,
                telephone: null,
                position: null,
                businessProvider: null,
                expectedDate: null,
                trackingStage: null,
                followPerson: null,
                followId: null,
                developmentId: null,
                transactionId: null,
                developmentManager: null,
                businessManager: null,
                collaboratorId: null,
                collaboratorName: null,
                creationTime: null,
                operateTime: null,
                operateId: null,
                departmentId: null,
                departmentName: null,
                organizationId: null,
                organizationName: null,
            },
            // 表单参数
            form: {
                creationTime: this.showDate(),
                classificationId: this.classId == "" ? '650c44e1-b575-4b62-9d54-1ba9d1e8abb7' : this.classId,
                creationName: this.$store.state.user.name
            },
            // 表单校验
            rules: {
                enterpriseName: [
                    { required: true, validator: enterpriseName, trigger: "blur" },
                ],
                contacts: [
                    { required: true, validator: contacts, trigger: "blur" },
                    { max: 25, message: '联系人姓名长度不能超过25', trigger: 'blur' }
                ],
                telephone: [
                    { required: true, validator: telephone, trigger: "blur" },
                    { max: 50, message: '联系人电话长度不能超过50', trigger: 'blur' }
                ],
                position: [
                    { max: 10, message: '联系人职位长度不能超过10', trigger: 'blur' }
                ],
                businessName: [
                    { required: true, message: "商机名称不能为空", trigger: "blur" },
                    { max: 50, message: '商机名称长度不能超过50', trigger: 'blur' }
                ],
                classificationId: [
                    { required: true, validator: classificationId, trigger: "blur" }
                ],
                businessType: [
                    { required: true, message: "商机类型不能为空", trigger: "change" },
                ],
                businessState: [
                    { required: true, message: "商机状态不能为空", trigger: "change" },
                ],
                businessSource: [
                    { required: true, message: "商机来源不能为空", trigger: "change" },
                ],

                expectedDate: [
                    { required: true, message: "预计成交时间不能为空", trigger: "blur" },
                ],
                businessProvider: [
                    { required: true, message: "商机提供人不能为空", trigger: "blur" },
                    { max: 25, message: '商机提供人长度不能超过25', trigger: 'blur' }
                ],
                trackingStage: [
                    { required: true, message: "跟单阶段不能为空", trigger: "change" },
                ],
                industry: [
                    { required: true, message: "所属行业不能为空", trigger: "blur" },
                ],
                developmentManager: [
                    { required: true, validator: developmentManager, trigger: "change" }
                ],
                businessManager: [
                    { required: true, validator: businessManager, trigger: "change" }
                ],
                collaboratorName: [
                    { required: true, validator: collaboratorName, trigger: "change" },
                ],

            },
            businessId: null,
            optionData: null,
            querySeasParams: {
                pageNum: 1,
                pageSize: 5,
                enterpriseName: null,
                administrativeArea: null,
                enterpriseNature: null,
                industry: null,
                classificationId: null
            },
            queryEnterpriseParams: {
                pageNum: 1,
                pageSize: 5,
                enterpriseName: null,
                enterpriseSource: null,
                enterpriseAbbreviation: null,
                administrativeArea: null,
                legalRepresentative: null,
                establishmentDate: null,
                contractAmount: null,
                enterpriseLabel: null,
                registeredCapital: null,
                industry: null,
                contacts: null,
                telephone: null,
                bankName: null,
                taxId: null,
                developmentId: null,
                transactionId: null,
                developmentManager: null,
                businessManager: null,
                enterpriseAddress: null,
                businessScope: null,
                enterpriseNature: null,
                markAs: '1',
                belongTo: null,
                creationTime: null,
                operateTime: null,
                operateId: null,
                departmentId: null,
                departmentName: null,
                organizationId: null,
                organizationName: null,
                classificationId: null
            },
        };
    },
    created() {
        this.listType();
        this.getEnterpriseList();
        this.getSeasList();
        if (this.$route.params.enterpriseId != "" && this.$route.params.enterpriseId != null && this.$route.params.enterpriseId != undefined) {
            getSupplierInfo(this.$route.params.enterpriseId).then(response => {
                this.$nextTick(() => {
                    this.$set(this.form, 'contacts', response.data.contacts)
                    this.$set(this.form, 'telephone', response.data.telephone)
                    this.$set(this.form, 'enterpriseName', response.data.enterpriseName)
                    this.form.enterpriseId = response.data.enterpriseId
                })
            });
            this.opt = "add"
            this.fileType = 0;
            this.isOpt = false;
            this.bId = this.guid();
            this.businessId = this.guid();
            this.isSwitch = this.isClick;
            if (this.enterpriseId != "" && this.enterpriseId != null) {
                this.form.enterpriseId = this.enterpriseId;
                this.form.enterpriseName = this.enterpriseName;
            }
        }


    },
    methods: {
        submitFormOnce() {
            this.fileType = 0;
            this.reset();
            this.refreshKey++;
            this.form.creationTime = this.showDate();
            this.form.classificationId = this.classId == "" ? '650c44e1-b575-4b62-9d54-1ba9d1e8abb7' : this.classId;
            this.form.creationName = this.$store.state.user.name;
            this.form.businessId = this.guid();
            this.isOpt = false;
            this.businessId = this.form.businessId;
            this.bId = this.form.businessId;
            this.isSwitch = true;
            this.isTwoSave = false;
        },
        /** 搜索按钮操作 */
        handleQueryEnterprise() {
            this.queryEnterpriseParams.pageNum = 1;
            this.getEnterpriseList();
        },
        /** 重置按钮操作 */
        resetQueryEnterprise() {
            this.resetForm("queryFormEnterprise");
            this.handleQueryEnterprise();
        },
        /** 搜索按钮操作 */
        handleQuerySeas() {
            this.querySeasParams.pageNum = 1;
            this.getSeasList();
        },
        /** 重置按钮操作 */
        resetQuerySeas() {
            this.resetForm("queryFormSeas");
            this.handleQuerySeas();
        },
        getEnterpriseList() {
            this.loading = true;
            listInfo(this.queryEnterpriseParams).then(response => {
                this.infoList = response.rows;
                this.total1 = response.total;
                this.loading = false;
            });
        },
        getSeasList() {
            this.loading = true;
            listSeas(this.querySeasParams).then(response => {
                this.seasList = response.rows;
                this.total2 = response.total;
                this.loading = false;
            });
        },
        getFile(data) {
            console.log(JSON.stringify(data))
        },
        listType() {
            listType({ typeCode: 'business' }).then(res => {
                this.optionData = res.data;
            })
        },
        beforeHandle() {
            if (3 == "no") {
                this.$message.error("请先保存商机基本信息！");
            } else {

            }
        },
        handleClick(tab, event) {
            if (tab.name == 'first') {

            }
            if (tab.name == 'second') {

            }
        },
        handleNewClick(tab, event) {
            if (tab.name == 'one') {
                this.$refs.tableSeas.clearSelection(); // 清空所有选择
            }
            if (tab.name == 'two') {
                this.$refs.tableEnterprise.clearSelection(); // 清空所有选择
            }
        },
        userShow(type) {
            this.show = type
            this.$refs.select.show();

        },
        // 取消按钮
        cancel() {
            this.$route.params.enterpriseId == ""
            //关闭当前页面
            const obj = { path: "/enterpriseInfo/sale/businessinfo" };
            this.$tab.closeOpenPage(obj);
            //跳转指定路由页面
            this.$router.push("/enterprise/relationship");
        },
        // 表单重置
        reset() {
            this.form = {
                businessId: null,
                businessName: null,
                classificationId: null,
                enterpriseId: null,
                enterpriseName: null,
                businessState: null,
                businessType: null,
                businessSource: null,
                contacts: null,
                telephone: null,
                position: null,
                businessProvider: null,
                expectedDate: null,
                trackingStage: null,
                followPerson: null,
                followId: null,
                developmentId: null,
                transactionId: null,
                developmentManager: null,
                businessManager: null,
                collaboratorId: null,
                collaboratorName: null,
                creationTime: null,
                operateTime: null,
                operateId: null,
                departmentId: null,
                departmentName: null,
                organizationId: null,
                organizationName: null,
                delFlag: null
            };
            this.resetForm("form");
        },
        /** 修改按钮操作 */
        handleUpdate(id) {
            this.reset();
            getInformation(id).then(response => {
                this.reset();
                this.form = response.data;
                this.form.creationTime = this.formatterDate(this.form.creationTime)
            });
        },
        /** 提交按钮 */
        submitForm() {
            if (this.opt == "add" || this.opt == "edit") {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        if (this.opt == "add") {
                            this.form.businessId = this.businessId;
                            this.bId = this.form.businessId;
                            this.business = null;
                        }
                        updateInformation(this.form).then(response => {
                            this.isSwitch = false;
                            this.$modal.msgSuccess("保存成功");
                            this.business = null;
                            this.$route.params.enterpriseId == ""
                            // //关闭当前页面
                            // const obj = { path: "/enterpriseInfo/sale/businessinfo" };
                            // this.$tab.closeOpenPage(obj);
                            // //跳转指定路由页面
                            // //this.$router.push("/sale/businessinfo");
                            // this.$router.push("/enterprise/enterpriseinfo");
                        });
                    }
                });
            }
        },
        dateOptions(time) {
            return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
        },
        showDate() {
            var mydate = new Date();
            var str = "" + mydate.getFullYear() + "-";
            str += (mydate.getMonth() + 1) <= 9 ? "0" + (mydate.getMonth() + 1) + "-" : mydate.getMonth() + 1 + "-";
            str += mydate.getDate() <= 9 ? "0" + mydate.getDate() : mydate.getDate();
            return str;
        },
        formatterDate(date) {
            var mydate = new Date(date);
            var str = "" + mydate.getFullYear() + "-";
            str += (mydate.getMonth() + 1) <= 9 ? "0" + (mydate.getMonth() + 1) + "-" : mydate.getMonth() + 1 + "-";
            str += mydate.getDate() <= 9 ? "0" + mydate.getDate() : mydate.getDate();
            return str;
        },
        close() {
            this.open = false;
        },
        enterprise() {
            this.open = true;
        },
        selectUser(userId, userName, phone, position) {
            if (this.show == '2') {
                this.$set(this.form, 'developmentManager', userName)
                this.$set(this.form, 'developmentId', userId)
            } else if (this.show == '3') {
                this.$set(this.form, 'businessManager', userName)
                this.$set(this.form, 'transactionId', userId)
            } else if (this.show == '4') {
                this.$set(this.form, 'collaboratorName', userName)
                this.$set(this.form, 'collaboratorId', userId)
            }
        },
        handleSelectionChangeSeas(selection) {
            if (selection.length > 1) {
                this.$refs.tableSeas.clearSelection(); // 清空所有选择
                this.$refs.tableSeas.toggleRowSelection(selection.pop()); // 设置选择项
            } else {
                this.sIds = selection.map(item => item.enterpriseId)
                this.sName = selection.map(item => item.enterpriseName)
                this.sContacts = selection.map(item => item.contacts)
                this.sTeles = selection.map(item => item.telephone)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            }
        },
        guid() {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            }
            return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
        },
        handleSelectionChangeEnterprise(selection) {
            if (selection.length > 1) {
                this.$refs.tableEnterprise.clearSelection(); // 清空所有选择
                this.$refs.tableEnterprise.toggleRowSelection(selection.pop()); // 设置选择项
            } else {
                this.eIds = selection.map(item => item.enterpriseId)
                this.eName = selection.map(item => item.enterpriseName)
                this.eContacts = selection.map(item => item.contacts)
                this.eTeles = selection.map(item => item.telephone)
                this.single = selection.length !== 1
                this.multiple = !selection.length
            }
        },
        getNodeEnterprise(data, node, obj) {
            this.queryEnterpriseParams.classificationId = data.id
            console.log(data.id)
            this.getEnterpriseList()
        },
        getNodeSeas(data, node, obj) {
            this.querySeasParams.classificationId = data.id
            this.getSeasList()
        },
        saveSelectEnterprise() {
            if (this.eIds.toString() == "" || this.eIds.toString() == null) {
                this.$modal.msgError("请先选择客户！");
            } else {
                this.$set(this.form, 'enterpriseName', this.eName.toString())
                this.$set(this.form, 'enterpriseId', this.eIds.toString())
                this.$set(this.form, 'contacts', this.eContacts.toString())
                this.$set(this.form, 'telephone', this.eTeles.toString())
                this.close()
            }
        },
        saveSelectSeas() {
            this.$set(this.form, 'enterpriseName', this.sName.toString())
            this.$set(this.form, 'enterpriseId', this.sIds.toString())
            this.$set(this.form, 'contacts', this.sContacts.toString())
            this.$set(this.form, 'telephone', this.sTeles.toString())
            this.close()
        }
    }
};
</script>

<style scoped lang="scss">
::v-deep .el-table .el-table__header-wrapper .el-checkbox {
    display: none;
}

::v-deep .el-dialog__header {
    padding-top: 5px;
}
</style>
